<?php
/**
 * Bookmarks sidebar
 */
/**
 * GolfScore sidebar
 *
 * @package Elgg
 *
 * @uses $vars['view_type']   all, owner
 * @uses $vars['items']       Array of ElggEntity or ElggAnnotation objects
 * @uses $vars['offset']      Index of the first list item in complete list
 * @uses $vars['limit']       Number of items per page. Only used as input to pagination.
 * @uses $vars['count']       Number of items in the complete list
 * @uses $vars['base_url']    Base URL of list (optional)
 * @uses $vars['pagination']  Show pagination? (default: true)
 * @uses $vars['position']    Position of the pagination: before, after, or both
 * @uses $vars['full_view']   Show the full view of the items (default: false)
 * @uses $vars['list_class']  Additional CSS class for the <ul> element
 * @uses $vars['item_class']  Additional CSS class for the <li> elements
 */
$owner = elgg_get_page_owner_entity();
//$user = elgg_get_logged_in_user_entity();

$view_type = ($owner->type=='user'? 'owner' : 'all');

$defaults = array(
		'on_sidebar' => true, 
		'view_type' => $view_type,
);

if(!isset($options)) {
	$options = array();
}
$options = array_merge($defaults, $options);

$guid='';
if (elgg_is_active_plugin('customactivity')) {
	$options['base_url'] = "ajax/view/golfscore/previous?guid=$guid";
}
if($view_type == 'all') {
	$title = elgg_echo('golfscore:all');
	$content = elgg_list_golf_score($options);
} else {
	$title = elgg_echo('golfscore:owner', array($owner->name));
	
	if($owner->guid == elgg_get_logged_in_user_guid()){
		$btnAdd = '<div class="add-score">' . elgg_view('output/url', array(
				'href' => "golfscore/add",
				'text' => elgg_echo('golfscore:add'),
				'is_trusted' => true,
		)) . '</div>';
		$title .=$btnAdd;
	}
	
	$options = array_merge($options, array('user_entity_id'=>$owner->guid));
	$guid=$owner->guid;
	if (elgg_is_active_plugin('customactivity')) {
		$options['base_url'] = "ajax/view/golfscore/previous?guid=$guid";
	}
	$content = elgg_list_golf_score($options);
}
echo elgg_view_module('featured',  $title, $content,'' );
